﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HangYi_Coffee_Class.Migrations
{
    /// <inheritdoc />
    public partial class sda : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Cup_typeOption_Details_DetailId",
                table: "Cup_typeOption");

            migrationBuilder.DropForeignKey(
                name: "FK_Details_Sorts_SortId",
                table: "Details");

            migrationBuilder.DropForeignKey(
                name: "FK_IceOptions_Details_DetailId",
                table: "IceOptions");

            migrationBuilder.DropForeignKey(
                name: "FK_SugarOptions_Details_DetailId",
                table: "SugarOptions");

            migrationBuilder.DropForeignKey(
                name: "FK_TemperatureOptions_Details_DetailId",
                table: "TemperatureOptions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Cup_typeOption",
                table: "Cup_typeOption");

            migrationBuilder.DropColumn(
                name: "Order_Detail_Id",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "DateTime",
                table: "Details");

            migrationBuilder.DropColumn(
                name: "Sales",
                table: "Details");

            migrationBuilder.DropColumn(
                name: "Cup_type",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "Description",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "Ice",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "Sugar",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "Temperature",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "Type",
                table: "Commoditys");

            migrationBuilder.RenameTable(
                name: "Cup_typeOption",
                newName: "Cup_typeOptions");

            migrationBuilder.RenameColumn(
                name: "Address",
                table: "Users",
                newName: "Role");

            migrationBuilder.RenameColumn(
                name: "DetailId",
                table: "TemperatureOptions",
                newName: "CommodityId");

            migrationBuilder.RenameIndex(
                name: "IX_TemperatureOptions_DetailId",
                table: "TemperatureOptions",
                newName: "IX_TemperatureOptions_CommodityId");

            migrationBuilder.RenameColumn(
                name: "DetailId",
                table: "SugarOptions",
                newName: "CommodityId");

            migrationBuilder.RenameIndex(
                name: "IX_SugarOptions_DetailId",
                table: "SugarOptions",
                newName: "IX_SugarOptions_CommodityId");

            migrationBuilder.RenameColumn(
                name: "DetailId",
                table: "IceOptions",
                newName: "CommodityId");

            migrationBuilder.RenameIndex(
                name: "IX_IceOptions_DetailId",
                table: "IceOptions",
                newName: "IX_IceOptions_CommodityId");

            migrationBuilder.RenameColumn(
                name: "SortId",
                table: "Details",
                newName: "OrderId");

            migrationBuilder.RenameIndex(
                name: "IX_Details_SortId",
                table: "Details",
                newName: "IX_Details_OrderId");

            migrationBuilder.RenameColumn(
                name: "DetailId",
                table: "Cup_typeOptions",
                newName: "CommodityId");

            migrationBuilder.RenameIndex(
                name: "IX_Cup_typeOption_DetailId",
                table: "Cup_typeOptions",
                newName: "IX_Cup_typeOptions_CommodityId");

            migrationBuilder.AddColumn<string>(
                name: "Name",
                table: "Users",
                type: "longtext",
                nullable: false)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Phone",
                table: "Users",
                type: "longtext",
                nullable: false)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Dining",
                table: "Orders",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Ice",
                table: "Orders",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<DateTime>(
                name: "Mealtime",
                table: "Orders",
                type: "datetime(6)",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "Ordertime",
                table: "Orders",
                type: "datetime(6)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Cup_type",
                table: "Details",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Sugar",
                table: "Details",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Temperature",
                table: "Details",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<DateTime>(
                name: "DateTime",
                table: "Commoditys",
                type: "datetime(6)",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Sales",
                table: "Commoditys",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "SortId",
                table: "Commoditys",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddPrimaryKey(
                name: "PK_Cup_typeOptions",
                table: "Cup_typeOptions",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "Address",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Phone = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    HouseNumber = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Linkman = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UserId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Address", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Address_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Commoditys_SortId",
                table: "Commoditys",
                column: "SortId");

            migrationBuilder.CreateIndex(
                name: "IX_Address_UserId",
                table: "Address",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_Commoditys_Sorts_SortId",
                table: "Commoditys",
                column: "SortId",
                principalTable: "Sorts",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Cup_typeOptions_Commoditys_CommodityId",
                table: "Cup_typeOptions",
                column: "CommodityId",
                principalTable: "Commoditys",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Details_Orders_OrderId",
                table: "Details",
                column: "OrderId",
                principalTable: "Orders",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_IceOptions_Commoditys_CommodityId",
                table: "IceOptions",
                column: "CommodityId",
                principalTable: "Commoditys",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_SugarOptions_Commoditys_CommodityId",
                table: "SugarOptions",
                column: "CommodityId",
                principalTable: "Commoditys",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_TemperatureOptions_Commoditys_CommodityId",
                table: "TemperatureOptions",
                column: "CommodityId",
                principalTable: "Commoditys",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Commoditys_Sorts_SortId",
                table: "Commoditys");

            migrationBuilder.DropForeignKey(
                name: "FK_Cup_typeOptions_Commoditys_CommodityId",
                table: "Cup_typeOptions");

            migrationBuilder.DropForeignKey(
                name: "FK_Details_Orders_OrderId",
                table: "Details");

            migrationBuilder.DropForeignKey(
                name: "FK_IceOptions_Commoditys_CommodityId",
                table: "IceOptions");

            migrationBuilder.DropForeignKey(
                name: "FK_SugarOptions_Commoditys_CommodityId",
                table: "SugarOptions");

            migrationBuilder.DropForeignKey(
                name: "FK_TemperatureOptions_Commoditys_CommodityId",
                table: "TemperatureOptions");

            migrationBuilder.DropTable(
                name: "Address");

            migrationBuilder.DropIndex(
                name: "IX_Commoditys_SortId",
                table: "Commoditys");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Cup_typeOptions",
                table: "Cup_typeOptions");

            migrationBuilder.DropColumn(
                name: "Name",
                table: "Users");

            migrationBuilder.DropColumn(
                name: "Phone",
                table: "Users");

            migrationBuilder.DropColumn(
                name: "Dining",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "Ice",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "Mealtime",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "Ordertime",
                table: "Orders");

            migrationBuilder.DropColumn(
                name: "Cup_type",
                table: "Details");

            migrationBuilder.DropColumn(
                name: "Sugar",
                table: "Details");

            migrationBuilder.DropColumn(
                name: "Temperature",
                table: "Details");

            migrationBuilder.DropColumn(
                name: "DateTime",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "Sales",
                table: "Commoditys");

            migrationBuilder.DropColumn(
                name: "SortId",
                table: "Commoditys");

            migrationBuilder.RenameTable(
                name: "Cup_typeOptions",
                newName: "Cup_typeOption");

            migrationBuilder.RenameColumn(
                name: "Role",
                table: "Users",
                newName: "Address");

            migrationBuilder.RenameColumn(
                name: "CommodityId",
                table: "TemperatureOptions",
                newName: "DetailId");

            migrationBuilder.RenameIndex(
                name: "IX_TemperatureOptions_CommodityId",
                table: "TemperatureOptions",
                newName: "IX_TemperatureOptions_DetailId");

            migrationBuilder.RenameColumn(
                name: "CommodityId",
                table: "SugarOptions",
                newName: "DetailId");

            migrationBuilder.RenameIndex(
                name: "IX_SugarOptions_CommodityId",
                table: "SugarOptions",
                newName: "IX_SugarOptions_DetailId");

            migrationBuilder.RenameColumn(
                name: "CommodityId",
                table: "IceOptions",
                newName: "DetailId");

            migrationBuilder.RenameIndex(
                name: "IX_IceOptions_CommodityId",
                table: "IceOptions",
                newName: "IX_IceOptions_DetailId");

            migrationBuilder.RenameColumn(
                name: "OrderId",
                table: "Details",
                newName: "SortId");

            migrationBuilder.RenameIndex(
                name: "IX_Details_OrderId",
                table: "Details",
                newName: "IX_Details_SortId");

            migrationBuilder.RenameColumn(
                name: "CommodityId",
                table: "Cup_typeOption",
                newName: "DetailId");

            migrationBuilder.RenameIndex(
                name: "IX_Cup_typeOptions_CommodityId",
                table: "Cup_typeOption",
                newName: "IX_Cup_typeOption_DetailId");

            migrationBuilder.AddColumn<int>(
                name: "Order_Detail_Id",
                table: "Orders",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "DateTime",
                table: "Details",
                type: "datetime(6)",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Sales",
                table: "Details",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Cup_type",
                table: "Commoditys",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Description",
                table: "Commoditys",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Ice",
                table: "Commoditys",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Sugar",
                table: "Commoditys",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Temperature",
                table: "Commoditys",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Type",
                table: "Commoditys",
                type: "longtext",
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Cup_typeOption",
                table: "Cup_typeOption",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Cup_typeOption_Details_DetailId",
                table: "Cup_typeOption",
                column: "DetailId",
                principalTable: "Details",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Details_Sorts_SortId",
                table: "Details",
                column: "SortId",
                principalTable: "Sorts",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_IceOptions_Details_DetailId",
                table: "IceOptions",
                column: "DetailId",
                principalTable: "Details",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_SugarOptions_Details_DetailId",
                table: "SugarOptions",
                column: "DetailId",
                principalTable: "Details",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_TemperatureOptions_Details_DetailId",
                table: "TemperatureOptions",
                column: "DetailId",
                principalTable: "Details",
                principalColumn: "Id");
        }
    }
}
